package org.gruposp2p.aularest.server;

import java.util.logging.Logger;
import org.gruposp2p.aularest.utils.AulaLogger;

/**
 *
 * @author jj
 */
public class LinkConstants {

    private static final Logger logger =
        AulaLogger.getLogger(AulaApplication.class.getName());

    // Absence
    private static String ABSENCE_BASE_PATH = "/absence/";
    public static String ABSENCE_PATH = ABSENCE_BASE_PATH + "{absenceID}";
    public static String ABSENCES_PATH = "/absences";

    // Student
    private static String STUDENT_BASE_PATH = "/student/";
    public static String STUDENT_PATH = "/student/{studentID}";
    public static String STUDENTS_PATH = "/students";
    
    // Photo
    public static String PHOTO_BASE_PATH = "/PhotoServlet?studentId=";
    public static String PHOTO_PATH = "/photo/{photoID}";

    // Course
    private static String COURSE_BASE_PATH = "/course/";
    public static String COURSE_PATH = COURSE_BASE_PATH + "{courseID}";
    public static String COURSES_PATH = "/courses";

    //Coursegroup
    private static String COURSEGROUP_BASE_PATH = "/coursegroup/";
    public static String COURSEGROUP_PATH = COURSEGROUP_BASE_PATH + "{coursegroupID}";
    public static String COURSEGROUPS_PATH = "/coursegroups";
    public static String COURSEGROUPS_COURSE_PATH = "/course/{courseID}/coursegroups";

    //Address
    private static String ADDRESS_BASE_PATH = "/address/";
    public static String ADDRESS_PATH = ADDRESS_BASE_PATH + "{addressID}";
    public static String ADDRESSES_PATH = "/addresses";

    //Tutor
    private static String TUTOR_BASE_PATH = "/tutor/";
    public static String TUTOR_PATH = TUTOR_BASE_PATH + "{tutorID}";
    public static String TUTORS_PATH = "/tutors";

    //Score
    private static String SCORE_BASE_PATH = "/score/";
    public static String SCORE_PATH = SCORE_BASE_PATH + "{scoreID}";
    public static String SCORES_PATH = "/scores";

    //Itemcalificable
    private static String ITEMCALIFICABLE_BASE_PATH = "/itemcalificable/";
    public static String ITEMCALIFICABLE_PATH = ITEMCALIFICABLE_BASE_PATH + "{itemcalificableID}";
    public static String ITEMCALIFICABLES_PATH = "/itemcalificables";

    //Itemcalificabletype
    private static String ITEMCALIFICABLETYPE_BASE_PATH = "/itemcalificabletype/";
    public static String ITEMCALIFICABLETYPE_PATH = ITEMCALIFICABLETYPE_BASE_PATH + "{itemcalificabletypeID}";
    public static String ITEMCALIFICABLETYPES_PATH = "/itemcalificabletypes";

    //Subject
    private static String SUBJECT_BASE_PATH = "/subject/";
    public static String SUBJECT_PATH = SUBJECT_BASE_PATH + "{subjectID}";
    public static String SUBJECTS_PATH = "/subjects";

    //Competence
    private static String COMPETENCE_BASE_PATH = "/competence/";
    public static String COMPETENCE_PATH = COMPETENCE_BASE_PATH + "{competenceID}";
    public static String COMPETENCES_PATH = "/competences";

    private static String HOST = "http://localhost:9090/AulaRest/service";

    public static String getCourseLink (String cursoID) {
        return HOST + COURSE_BASE_PATH + cursoID;
    }

    public static String getCoursegroupLink (String coursegroupID) {
        return HOST + COURSEGROUP_BASE_PATH + coursegroupID;
    }

    public Integer getCoursegroupIdFromLink (String link) {
        int baseUrlSize = (HOST + COURSEGROUP_BASE_PATH).length();
        String id = link.substring(baseUrlSize);
        return new Integer (id);
    }

    public static String getAbsenceLink (String absenceID) {
        return HOST + ABSENCE_BASE_PATH + absenceID;
    }

    public static String getAddressLink (String addressID) {
        return HOST + ADDRESS_BASE_PATH + addressID;
    }

    public static String getCompetenceLink (String competenceID) {
        return HOST + COMPETENCE_BASE_PATH + competenceID;
    }

    public static String getItemcalificableLink (String itemcalificableID) {
        return HOST + ITEMCALIFICABLE_BASE_PATH + itemcalificableID;
    }

    public static String getItemcalificabletypeLink (String itemcalificabletypeID) {
        return HOST + ITEMCALIFICABLETYPE_BASE_PATH + itemcalificabletypeID;
    }

    public static String getScoreLink (String scoreID) {
        return HOST + SCORE_BASE_PATH + scoreID;
    }

    public static String getStudentLink (String studentID) {
        return HOST + STUDENT_BASE_PATH + studentID;
    }

    public static String getSubjectLink (String subjectID) {
        return HOST + SUBJECT_BASE_PATH + subjectID;
    }

    public static String getTutorLink (String tutorID) {
        return HOST + TUTOR_BASE_PATH + tutorID;
    }

    public static String getPhotoLink (String studentID) {
        return HOST + PHOTO_BASE_PATH + studentID;
    }
}
